package com.kabigon.multiverse.exception;

import lombok.EqualsAndHashCode;

/**
 * 基础的异常类，其他子类要继承
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.multiverse.exception
 * @data 2022/2/17 22:25
 */
@EqualsAndHashCode(callSuper = true)
public abstract class BaseException extends RuntimeException {

    /**
     * 异常状态码
     */
    protected int code;
    /**
     * 异常描述
     */
    protected String description;

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    public BaseException(String message) {
        super(message);
    }

    public static UndefinedException undefinedException(Throwable e) {
        return new UndefinedException(e);
    }

    /**
     * 获取状态码
     *
     * @return int
     */
    public abstract int getCode();

    /**
     * 获取异常描述
     *
     * @return {@link String}
     */
    public abstract String getDescription();

}
